package com.some;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Scanner;

public class Didi_02 {

    public String subStr(int[] arr) {
        int n = arr.length;
        int flag = 0;
        int count = 0;
        for (int i = 1; i < n; i++) {
            if (arr[i - 1] < arr[i]) {
                if (flag == 0) {
                    flag = 1;
                }
                if (flag == -1) {
                    flag = 0;
                    count++;
                }
            } else if (arr[i - 1] > arr[i]) {
                if (flag == 0) {
                    flag = -1;
                }
                if (flag == 1) {
                    flag = 0;
                    count++;
                }
            }
        }
        return count == 2 ? "Yes" : "No";
    }

    public static void main(String[] args) {
        Didi_02 didi_02 = new Didi_02();
        Scanner sc = new Scanner(System.in);
        ArrayList<String> list = new ArrayList<>();
        int T = sc.nextInt();
        for (int i = 0; i < T; i++) {
            int n = sc.nextInt();
            int[] ints = new int[n];
            for (int j = 0; j < n; j++) {
                ints[j] = sc.nextInt();
            }
            list.add(didi_02.subStr(ints));
        }
        for (String s : list) {
            System.out.println(s);
        }

/*        LinkedList<Integer> list1 = new LinkedList<>();
        Integer last = list1.getLast();*/
    }
}
